package com.szy.douyou_article.dao.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.szy.douyou_article.dao.Article;
import com.szy.douyou_article.dao.State;
import com.szy.douyou_article.dao.req.ArticleReq;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * @author sunziyan
 * @date 2022/3/1
 */
@Mapper
public interface ArticleMapper extends BaseMapper<Article> {

    /**
     * 分页条件查询帖子
     * @param page
     * @param articleReq
     * @return
     */
    Page<Article> pageQueryArticleByArticleReq(Page<Article> page, @Param("req")ArticleReq articleReq);

    /**
     * 新增帖子
     * @param article
     * @return
     */
    Integer insertClassificationArticle(@Param("article")Article article);

    /**
     * 更新文章分类关系表
     * @param article
     * @return
     */
    Integer updateClassificationArticle(@Param("article")Article article);

    /**
     * 删除分类文章关系表
     * @param articleId
     * @return
     */
    Integer deleteClassificationArticleByArticleId(@Param("articleId")Long articleId);

    /**
     * 有人浏览时浏览数加1
     * @param articleId
     * @return
     */
    Integer updateArticleViews(Long articleId);


    /**
     * 获取该文章好评数
     * @param state
     * @return
     */
    Integer getArticleGoodStateCount(@Param("state")State state);

    /**
     * 获取该文章差评数
     * @param state
     * @return
     */
    Integer getArticleBadStateCount(@Param("state")State state);

    /**
     * 获取我的文章评价
     * @param state
     * @return
     */
    Integer getMyArticleState(@Param("state")State state);

    /**
     * 插入文章评价
     * @param state
     * @return
     */
    Integer insertArticleState(@Param("state")State state);

    Integer updateArticleState(@Param("state")State state);

}
